<php>
unset($alert_message);
//判断用户是否为外部直接登录
$user1 = M('User')->where("id='".$_SESSION['mid']."'")->find();
if( empty($user1) ){
	$alert_message="用户不存在！";
}else{
	if(!empty($user1['email'])){
		$alert_message="用户非外部账号直接登录！";
	}
}  
//$alert_message="用户不存在！";
</php>

<php>if( !empty($alert_message) ){</php>
	<include file="../Public/alert_box.html" />
<php>}else{</php>
<script>

function regLocalSubmit(){
	var checkresult=checkFormItems('regform');
	
	var form_ = $("#regform");
	if(checkresult){
		alert(checkresult);
		//提交表单
		$.kajax({      
			ajx_rtn_type:'JSON',
			url:"{:U('Index://Public/doRegisterLocal')}",      
			type:'post', //数据发送方式  
			data:{email:form_.find('#email').val(),password:form_.find('#password').val(),repassword:form_.find('#repassword').val()} ,    
			async: false ,//同步方式     
			success: function(objson){ 
							if(objson.status==1){
								k_success(objson.msg);
							}else{
								k_error(objson.msg);
							}
			}
		});
	}
	//"{:U('User://Account/doRegisterLocal')}";
}

</script>
<style>
.reglogin_btn {
    background: url("/Public/Images/global/reglogin_btn.gif") no-repeat scroll 0 0 transparent;
    border: medium none;
    color: #FFFFFF;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    height: 35px;
    line-height: 35px;
    text-align: center;
    width: 96px;
}
</style>
<!--表单验证-->
<script type="text/javascript" src="__PUBLIC__/Js/jquery.validator.reg.js"></script>
<script type="text/javascript" src="__PUBLIC__/Js/jquery.corners.min.js"></script>
<link href="__PUBLIC__/Js/form_check/type.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/Js/register.js" ></script>
<div class="reg_box" id="regist_area">
  <div style="width: auto; height: auto;padding:20px 0px;" class="do_box">
    <form action="" method="post" id="regform" name="reg">
    <table cellspacing="0" cellpadding="0" border="0" align="center" class="do_list">
      <tbody><tr>
        <td height="50" align="right" width="90" valign="middle"><span class="reg_item">Email：</span></td>
        <td width="205" valign="middle">
        <div class="mailline">
            <input type="text" class="do_input uemail s_input" value="" id="email"
            name="email" require="true" datatype="email|ajax" 
            url="{:U('Index://Public/isEmailAvailable')}" msg="格式错误|邮箱已注册"/>
        </div>
        </td>
        <td align="left" width="155" valign="middle">
        	<div id="success_email" style="display:none;"> <span class="ico_cue_ok"></span> </div>
          <div class="error_email" style="position: relative;display:none;"> <span class="ico_cue_no"></span><span id="error_email"></span> </div>
	
        </td>
      </tr>
      <tr>
        <td height="50" align="right" valign="middle"><span class="reg_item">密码：</span></td>
        <td valign="middle">
        	<input type="password" class="do_input psd_input s_input" 
        					name="password" id="password" require="true" value="" 
        					datatype="limit"  min="6" max="16" msg="6-16个字符"/>       
        </td>
        <td align="left" valign="middle">
        	<div id="success_password"  style="display:none;"> <span class="ico_cue_ok"></span> </div>
          <div class="error_password" style="position: relative;display:none;"> <span class="ico_cue_no"></span> <span id="error_password"></span> </div>
        </td>
      </tr>
      <tr>
        <td height="50" align="right" valign="middle"><span class="reg_item">确认密码：</span></td>
        <td valign="middle">
        	<input type="password" class="do_input psd_input s_input" id="repassword"
        					name="repassword" require="true" value="" datatype="repeat|limit"  
        					min="6" max="16" to="password" msg="确认密码错误|请再输入一次"/>  
        </td>
        <td align="left" valign="middle">
        	<div id="success_repassword"  style="display:none;"> <span class="ico_cue_ok"></span> </div>
					<div class="r error_repassword" style="position: relative;display:none;"> <span class="ico_cue_no"></span> <span id="error_repassword"></span> </div>
        </td>
      </tr>
      <tr>
        <td height="56" align="right" valign="middle">&nbsp;</td>
        <td valign="middle" colspan="2">
        	<input type="button"  class="reglogin_btn" value="确&nbsp;定" name="checkbutton" onclick="regLocalSubmit();"></td>
      </tr>
    </tbody></table>
    
    </form>
  </div>
</div>

<php>}</php>